package com.xiashitech.agent.instrumentation.biz.userinfo.springsecurity;

import io.opentelemetry.javaagent.shaded.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.shaded.io.opentelemetry.api.GlobalOpenTelemetry;

public class XSAuthenticationSingletons {
    private XSAuthenticationSingletons() {
    }

    private static final String INSTRUMENTATION_NAME = "com.xiashitech.biz.user.springsecurity";
    private static final String SPAN_NAME = "xs.user-springsecurity-span";
    private static final Instrumenter<AuthenticationData, Void> INSTRUMENTER;

    public static Instrumenter<AuthenticationData, Void> instrumenter() {
        return INSTRUMENTER;
    }

    static {
        INSTRUMENTER =
                Instrumenter.<AuthenticationData, Void>builder(
                        GlobalOpenTelemetry.get(),
                        INSTRUMENTATION_NAME,
                        request -> SPAN_NAME
                ).addAttributesExtractor(new XSAuthenticationAttributesExtractor()).buildInstrumenter();
    }
}
